<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">
    <ui:define name="head">
        <title>门店设置</title>
    </ui:define>

    <ui:define name="form">
        <p:panel id="p1">
            <span>门店设置</span>
            <p:commandButton value="添加" actionListener="#{otherUserView.badd}"
                             process="@this" partialSubmit="true" update="dt"
                             oncomplete="triggerRowEdit('#fm\\:dt',0)"/>
        </p:panel>

        <p:panel id="p2">
            <p:remoteCommand name="upDt" update="dt" process="@this" partialSubmit="true"/>
            <p:dataTable id="dt" value="#{otherUserView.lazyShopList}" lazy="true" var="item_shop" editable="true"
                         widgetVar="dt" emptyMessage="无记录" styleClass="rowEdit" rowStyleClass="#{item_shop.isactive?'':'noAct'}"
                         paginator="true" paginatorPosition="bottom" rows="20" currentPageReportTemplate="共{totalPages}页, {totalRecords}条记录" 
                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {CurrentPageReport} 跳转到页: {JumpToPageDropdown}">
                <p:ajax event="rowEdit" listener="#{otherUserView.rowEdit}"/>
                <p:ajax event="rowEditCancel" listener="#{otherUserView.rowEditCancel}" oncomplete="upDt()"/>

                <p:column headerText="API" width="20">
                    <p:rowToggler rendered="#{item_shop.isactive}"/>
                </p:column>
                <p:column headerText="编辑" width="32">
                    <p:rowEditor/>
                </p:column>
                <p:column headerText="GSID" width="100" sortBy="#{item_shop.gsid}">
                    <p:cellEditor>
                        <f:facet name="output">#{item_shop.gsid}</f:facet>
                        <f:facet name="input"><h:outputText value="#{item_shop.gsid}" rendered="#{not empty item_shop.gsid}"/>
                            <p:inputText rendered="#{empty item_shop.gsid}" value="#{item_shop.gsid}"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="所属集团" width="150" filterBy="#{item_shop.groupid}" filterMatchMode="equals">
                    <f:facet name="filter">
                        <p:autoComplete completeMethod="#{otherUserView.completeCongroup}" forceSelection="true"
                                        var="ac_group" itemValue="#{ac_group}"
                                        panelStyle="width:200px" inputStyle="width:110px" dropdown="true"
                                        itemLabel="#{aliAppBean.groupHM[ac_group]} #{empty ac_group?'无':' ['.concat(ac_group).concat(']')}">
                            <p:ajax event="query" process="@this" partialSubmit="true"/>
                            <p:ajax event="itemSelect" onstart="PF('dt').filter()"/>
                            <p:ajax event="itemUnselect" onstart="PF('dt').filter()"/>
                        </p:autoComplete>
                    </f:facet>
                    <p:cellEditor>
                        <f:facet name="output">#{aliAppBean.groupHM[item_shop.groupid]}</f:facet>
                        <f:facet name="input">
                            <p:autoComplete value="#{item_shop.groupid}" completeMethod="#{otherUserView.completeCongroup}" forceSelection="true"
                                            var="ac_group2" itemValue="#{ac_group2}"
                                            panelStyle="width:200px" inputStyle="width:110px" dropdown="true" dropdownMode="blank"
                                            itemLabel="#{aliAppBean.groupHM[ac_group2]} #{empty ac_group2?'无':' ['.concat(ac_group2).concat(']')}">
                                <p:ajax event="query" process="@this" partialSubmit="true"/>
                                <p:ajax event="itemSelect" process="@this" partialSubmit="true"/>
                            </p:autoComplete>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="门店名称" width="180" sortBy="#{item_shop.name}" 
                          filterBy="#{item_shop.name}" filterMatchMode="contains" filterStyle="width:80%">
                    <p:cellEditor>
                        <f:facet name="output">#{item_shop.name}</f:facet>
                        <f:facet name="input"><p:inputText value="#{item_shop.name}"/></f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="授权ID">
                    <p:cellEditor>
                        <f:facet name="output">#{item_shop.authId}</f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{item_shop.authId}"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="商品体系授权ID" rendered="false" styleClass="break">
                    <p:cellEditor>
                        <f:facet name="output">#{item_shop.goodsAuthId}</f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{item_shop.goodsAuthId}"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="核销口碑店铺ShopID" rendered="false" styleClass="break">
                    <p:cellEditor>
                        <f:facet name="output">#{item_shop.alipayShopId}</f:facet>
                        <f:facet name="input">
                            <p:inputText value="#{item_shop.alipayShopId}"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
                <p:column headerText="是否有效" width="115" filterBy="#{item_shop.isactive}">
                    <f:facet name="filter">
                        <p:selectOneButton onchange="PF('dt').filter()">
                            <f:converter converterId="javax.faces.Boolean" />
                            <f:selectItem itemLabel="所有" itemValue="" />
                            <f:selectItem itemLabel="是" itemValue="true" />
                            <f:selectItem itemLabel="否" itemValue="false" />
                        </p:selectOneButton>
                    </f:facet>

                    <p:cellEditor>
                        <f:facet name="output"><h:outputText value="#{item_shop.isactive?'是':'否'}"/></f:facet>
                        <f:facet name="input">
                            <p:selectBooleanCheckbox value="#{item_shop.isactive}"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>

                <p:rowExpansion>
                    <h:panelGroup id="apiBtnGp" layout="block" styleClass="apiBtnGp">
                        <p:button value="创建店铺"  outcome="/page/shop/createShop.xhtml" target="_blank">
                            <f:param name="gsid" value="#{item_shop.gsid}"/>
                        </p:button>
                        <p:button value="店铺管理流水" outcome="/page/shop/shopApply.xhtml" target="_blank">
                            <f:param name="gsid" value="#{item_shop.gsid}"/>
                        </p:button>
                    </h:panelGroup>
                </p:rowExpansion>
            </p:dataTable>
        </p:panel>
    </ui:define>
</ui:composition>